﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;
using System.Drawing;


namespace Utility
{
    public class HpmUtility
    {
        public static string strTitleMain = "Quản Lý Bệnh Viện";
        public static string strHospitalName = "Bệnh Viện Thái Hòa";

        public static string strNgayHienTai = "";


        /// <summary>
        /// Build LookupEdit with Datasource as Datatable
        /// </summary>
        /// <param name="bLookup"></param>
        /// <param name="dataSouce"></param>
        /// <param name="displayMember"></param>
        /// <param name="valueMember"></param>
        /// <param name="defaultText"></param>
        public static void InitLookupEdit(DevExpress.XtraEditors.LookUpEdit bLookup, DataTable dataSouce, string displayMember, string valueMember, string defaultText = "")
        {
            bLookup.Properties.DataSource = dataSouce;
            bLookup.Properties.DisplayMember = displayMember;
            bLookup.Properties.ValueMember = valueMember;

            if (defaultText != "")
            {
                //MessageBox.Show(defaultText);
                bLookup.EditValue = bLookup.Properties.GetKeyValueByDisplayText(defaultText);
            }
        }


        /// <summary>
        /// Build LookupEdit with no Datasuource
        /// </summary>
        /// <param name="bLookup"></param>
        /// <param name="defaultText"></param>
        public static void InitLookupEdit(DevExpress.XtraEditors.LookUpEdit bLookup, string defaultText)
        {
            bLookup.EditValue = bLookup.Properties.GetKeyValueByDisplayText(defaultText);
        }



        public static void LoadImgeTo(DevExpress.XtraEditors.PictureEdit pictureBox, Byte[] imageData)
        {
            MemoryStream mem = new MemoryStream(imageData);
            pictureBox.Image = Image.FromStream(mem);
        }


        /// <summary>
        /// Build New Id for BenhNhan
        /// </summary>
        /// <returns></returns>
        public static string BuildNewId(string currentId)
        {
            int newId = int.Parse(currentId);
            return (newId + 1).ToString();
        }
    }
}
